﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace DataModel
{
    public class Author
    {
        [Column("ID")]
        public int ID { get; set; }
        [Column("NAME")]
        public string Name { get; set; }

        public virtual List<Book> Books { get; set; }
    }

    public class AuthorConfiguration : EntityTypeConfiguration<Author>
    {
        public AuthorConfiguration() 
        {
            HasKey(x => x.ID);            
            Property(x => x.ID).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            HasMany<Book>(x => x.Books);
            Property(x => x.Name).IsRequired();
            ToTable("AUTHOR");
        }
    }
}
